
	<link rel="stylesheet" href="__STATIC__/css/wapcomment.css"> 
	<div class="WapCommentBox">
		<div class="head">
			<div class="tag">全部评论</div>
			<div class="more"><button type="butter" onclick="post_comment(0)">发表评论</button></div>
		</div>
		<div class="ListComment">
			<?php if(is_array($listdb) || $listdb instanceof \think\Collection || $listdb instanceof \think\Paginator): $i = 0; $__LIST__ = $listdb;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$rs): $mod = ($i % 2 );++$i;?>
				<ul class="lists" id="comment_cnt_<?php echo $rs['id']; ?>">
					<ol class="icon"><a href="<?php echo get_url('user',$rs['uid']); ?>" target="_blank"><img src="<?php echo $rs['icon']; ?>" onerror="this.src='/public/static/images/nobody.gif'"/></a></ol>
					<li class="infos">
						<div class="name"><a href="<?php echo murl('member/msg/add',['uid'=>$rs['uid']]);?>" class="_pop"><?php echo $rs['username']; ?></a></div>
						<div class="comment"><?php echo $rs['content']; ?></div>
						<dl><dt><?php echo $rs['time']; ?></dt><dd><em onclick="dingcomment(<?php echo $rs['id']; ?>)"><i class="si si-like"></i> <a class="agree<?php echo $rs['id']; ?>"><?php echo $rs['agree']; ?></a></em> <span onclick="post_comment(<?php echo $rs['id']; ?>)"><i class="fa fa-commenting-o"></i> 回复</span>
						<?php if($rs['uid']==login_user('uid')||login_user('groupid')==3): ?><span onclick="del_comment(<?php echo $rs['id']; ?>)"><i class="fa fa-close"></i> 删除</span><?php endif; ?>
						</dd></dl>
						<div class="repalyinfs repalyinfs<?php echo $rs['id']; ?>">
							<?php if(is_array($rs['children']) || $rs['children'] instanceof \think\Collection || $rs['children'] instanceof \think\Paginator): $i = 0; $__LIST__ = $rs['children'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
							<div id="comment_cnt_<?php echo $vo['id']; ?>">
								<a href="<?php echo get_url('user',$vo['uid']); ?>" target="_blank"><?php echo $vo['username']; ?>：</a>
								<?php echo $vo['content']; ?>
								<?php if($vo['uid']==login_user('uid')||login_user('groupid')==3): ?><span onclick="del_comment(<?php echo $vo['id']; ?>)" style="float:right;"><i class="fa fa-close"></i> 删除</span><?php endif; ?>
							</div>
							<?php endforeach; endif; else: echo "" ;endif; ?>
						</div>
					</li>
				</ul>
			<?php endforeach; endif; else: echo "" ;endif; ?>
		</div>
		<div class="ShowMoreComment"><button type="butter" onclick="ShowMoreComment()">更多评论 <i class="fa fa-angle-double-down"></i></button></div>
	</div>
	
	<script type="text/javascript">
		var posturl,baseurl;
			posturl=baseurl="<?php echo fun("label@comment_api","posturl",$aid,$sysid,$cfg_array); ?>";
		var repalyid=0;
		var commentpage=1;
		function post_comment(pid){			
			if(pid>0){
				repalyid=pid;
				posturl=baseurl+"?pid="+pid;
			}
			layer.open({
			  type: 1,
			  skin: 'layui-layer-demo', //样式类名
			  area: ['320px', '280px'], //宽高
			  closeBtn: 0, //不显示关闭按钮
			  anim: 2,
			  shadeClose: true, //开启遮罩关闭
			  content: '<ul class="PostCommentBox"><ol><textarea placeholder="请输入评论内容"></textarea></ol><li><button type="butter" onclick="post_comment1()">发表</button><button type="butter" onclick="layer.closeAll()">取消</button></li></ul>'
			});
		}

function del_comment(id){
	layer.confirm('你确认要删除吗？',function(){
		$.get("<?php echo purl('comment/api/delete');?>?ids="+id,function(res){
			if(res.code==0){
				layer.msg('删除成功');
				$("#comment_cnt_"+id).hide();
			}else{
				layer.alert(res.msg);
			}
		});
	});
}
		function post_comment1(){
			var contents=$('.PostCommentBox textarea').val();
			if(contents==''){
				layer.alert("请输入评论内容！");
			}else{
				$.post(
					posturl,
					{content:contents},
					function(res,status){
						if(res.code==0){
							if(repalyid>0){
								$('.repalyinfs'+repalyid).html(res.data);
							}else{
								$('.ListComment').html(res.data);
								commentpage=1;
								//$('.ShowMoreComment').fadeIn();
							}
							layer.closeAll(); //疯狂模式，关闭所有层
							layer.msg('发表成功！');
							HiddenShowMoreComment();
						}else{
							layer.alert('评论发表失败:'+res.msg);
						}
					}
				);
			}
		}

		function dingcomment(id){
			var agree=parseInt($('.agree'+id).html());
			$.get('<?php echo fun("label@comment_api","posturl",$aid,$sysid,$cfg_array); ?>?agree=1&id='+id+'&'+Math.random(),function(res){
				if(res.code==0){
					agree++;
					$('.agree'+id).html(agree);
					layer.msg('点赞成功！');
				}else{
					layer.alert('点赞失败:'+res.msg);
				}
			});
		}

		function ShowMoreComment(){
			commentpage++;
			$.get('<?php echo fun("label@comment_api","pageurl",$aid,$sysid,$cfg_array); ?>?page='+commentpage+'&'+Math.random(),function(res){
				if(res.code==0){
					if(res.data==''){
						layer.msg('显示完了！');
						$('.ShowMoreComment').fadeOut();
					}else{
						res.data="<div class='pages"+commentpage+"'>"+res.data+"</div>";			
						$('.ListComment').append(res.data);
						$('.ListComment .pages'+commentpage).hide();
						$('.ListComment .pages'+commentpage).show(500);
					}
				}else{
					layer.msg(res.msg,{time:2500});
				}
			});
		}

		function HiddenShowMoreComment(){
			var Comments=$('.ListComment .lists').length;
			if(parseInt(Comments/<?php echo $cfg_array['rows']; ?>)<1){
				$('.ShowMoreComment').hide();
			}else{
				$('.ShowMoreComment').show();
			}
		}

		HiddenShowMoreComment();
	</script>

	 